package com.atguigu.srb.core.controller.admin;


import com.atguigu.srb.common.result.R;
import com.atguigu.srb.core.entity.Lend;
import com.atguigu.srb.core.entity.LendItem;
import com.atguigu.srb.core.service.LendItemService;
import com.atguigu.srb.core.service.LendService;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * <p>
 * 标的准备表 前端控制器
 * </p>
 *
 * @author Atguigu
 * @since 2023-06-30
 */
@RestController
@RequestMapping("/admin/core/lend")
@Api(tags = "标的管理模块")
public class AdminLendController {
    @Resource
    private LendService lendService;

    @ApiOperation("获取标的列表")
    @GetMapping("/list")
    public R list(){
        List<Lend> lendList = lendService.getLendsList();
        return R.ok().data("items",lendList);
    }
    @ApiOperation("根据标的id获取标的详情")
    @GetMapping("/detail/{lendId}")
    public R detail(@PathVariable("lendId")Long lendId){
        Map<String,Object> map = lendService.getDetailById(lendId);
        return R.ok().data(map);
    }
    //放款
    @ApiOperation("放款管理")
    @GetMapping("/makeLoan/{lendId}")
    public R makeLoan(@PathVariable("lendId")Long lendId){
        lendService.makeLoan(lendId);
        return R.ok();
    }
}

